import {HttpStatus} from './enum'

// 响应失败拦截
export function getResponseFailMessage(err) {
    let message = '请求错误'
    if (err && err.status) {
      switch (err.status) {
        case HttpStatus.RESERROR:
          message = '请求错误'
          break
  
        case HttpStatus.UNAUTHORIZED:
          message = '未授权，请登录'
          break
  
        case HttpStatus.ACCESSDENIED:
          message = '拒绝访问'
          break
  
        case HttpStatus.ADDRESSERROR:
          message = `请求地址出错: ${err.config.url}`
          break
  
        case HttpStatus.REQUESTTIMEOUT:
          message = '请求超时'
          break
  
        case HttpStatus.SERVERERROR:
          message = '服务器内部错误'
          break
  
        case HttpStatus.SERVICENO:
          message = '服务未实现'
          break
  
        case HttpStatus.BADGATEWAY:
          message = '网关错误'
          break
  
        case HttpStatus.SERVICENOTAV:
          message = '服务不可用'
          break
  
        case HttpStatus.GATEWAYTIMEOUT:
          message = '网关超时'
          break
  
        case HttpStatus.HTTPVERSIONNO:
          message = 'HTTP版本不受支持'
          break
  
        default:
          message = '请求错误'
      }
    }
  
    return message
  }
  